﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;

[assembly: TagPrefix("Jalal.Library.Web.Control", "ucc")]
namespace Jalal.Library.Web.Control
{
    [SupportsEventValidation, ValidationProperty("ImageUrl")]
    [ToolboxData("<{0}:ThemeHyperLink runat=server></{0}:ThemeHyperLink>")]
    public class ThemeHyperLink : HyperLink
    {
        protected override void OnInit(EventArgs e)
        {
            this.EnableViewState = false;
            base.OnInit(e);
        }

        protected override void OnLoad(EventArgs e)
        {
            if (!this.ImageUrl.Contains("~/App_Themes/"))
                base.ImageUrl = "~/App_Themes/" + Page.Theme + "/image/" + this.ImageUrl;
        }

        public override string ImageUrl
        {
            get
            {
                return base.ImageUrl;
            }
            set
            {
                if (Page != null && !string.IsNullOrEmpty(Page.Theme))
                    base.ImageUrl = "~/App_Themes/" + Page.Theme + "/image/" + value;
                else
                    base.ImageUrl = value;
            }
        }
    }
}
